package com.bawei.park2211a.adapter

import android.widget.ImageView
import android.widget.TextView
import androidx.cardview.widget.CardView
import com.bawei.base.bean.MessgaeEntity
import com.bawei.park2211a.R
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder

class MessageAdapter:BaseQuickAdapter<MessgaeEntity,BaseViewHolder>(R.layout.item_message) {
    override fun convert(helper: BaseViewHolder, item: MessgaeEntity) {
        helper.setText(R.id.msg_statu, item.messageStatus)
        helper.setText(R.id.msg_title, item.messageType)
        helper.setText(R.id.msg_message, item.messageContent)
        val img = helper.getView<CardView>(R.id.img)
        val img_type = helper.getView<ImageView>(R.id.img_type)
        val msg_statu = helper.getView<TextView>(R.id.msg_statu)
        when(item.messageStatus){
            "已读"->{
                msg_statu.setBackgroundResource(R.drawable.text_color2)
            }
            "已过期"->{
                msg_statu.setBackgroundResource(R.drawable.text_color1)
            }
            "处理中"->{
                msg_statu.setBackgroundResource(R.drawable.text_color3)
            }
        }
        when(item.messageType){
            "车位管理"->{
                img.setBackgroundResource(R.drawable.text_color4)
                img_type.setImageResource(R.drawable.smallcar)
            }
            "系统通知"->{
                img.setBackgroundResource(R.drawable.text_color2)
                img_type.setImageResource(R.drawable.baseline_campaign_24)
            }
            "物业服务"->{
                img.setBackgroundResource(R.drawable.text_color1)
                img_type.setImageResource(R.drawable.spanner)
            }
        }
    }
}